home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / Papers / aSEPiA example source / Application / CPlugin.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-25  |  1.1 KB  |  65 lines  |  [TEXT/CWIE]

  1. /*---------------------------------------------------------------
  2.  
  3.     CPlugin.h
  4.     
  5.     A wrapper class for a plugin.
  6.     
  7.     Provides an easy way to managed loading an unloading.
  8.     
  9. ---------------------------------------------------------------*/
  10.  
  11. #pragma once
  12.  
  13. #include "CodeFragments.h"
  14. #include "IInterfaceProvider.h"
  15. #include "IPluginInfoIntf.h"
  16.  
  17. typedef IInterfaceProvider* (*GetInterfaceProviderProc)();
  18.  
  19. class CPlugin
  20. {
  21. public:
  22.  
  23.                     CPlugin( FSSpec& inSpec);
  24.                     ~CPlugin();
  25.                 
  26.     virtual OSErr    Load( bool load = true);
  27.     virtual OSErr    Unload();
  28.     virtual bool    Valid();
  29.     
  30.     virtual bool     IsLoaded() { return mIsLoaded; };
  31.     
  32.     virtual OSErr    GetInterfacePointer( unsigned long inID, void** outInterfacePtr );
  33.     
  34.  
  35. protected:
  36.         FSSpec                mPluginSpec;    // the FSSpec of the plugin file
  37.         bool                mIsLoaded;
  38. CFragConnectionID            mConnID;
  39. GetInterfaceProviderProc    mGetIntfProc;
  40. IInterfaceProvider*         mIntfProvider;
  41.  
  42.         unsigned short        mRefCount;
  43.  
  44.  
  45. };
  46.  
  47.  
  48. class PluginLoader
  49. {
  50. public:
  51.  
  52.     PluginLoader( CPlugin* inPlugin ) 
  53.         { 
  54.             mPlugin = inPlugin; 
  55.             mPlugin->Load();
  56.         };
  57.     
  58.     ~PluginLoader()
  59.     {
  60.         mPlugin->Unload();
  61.     };
  62.  
  63. private:
  64.     CPlugin*    mPlugin;
  65. };